﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IllustratedCsharp7_ch20_Linq
{      
    class chapt20_6_5ExampleOfUsingDelegateParameters
    {
        static bool IsOdd(int x)    //委托对象使用的方法
        {
            return x % 2 == 1;      //如果x是奇数，返回true
        }

        static void _Main()
        {
            int[] intArray = new int[] { 3, 4, 5, 6, 7, 9 };

            Func<int, bool> myDel = new Func<int, bool>(IsOdd); //委托对象
            var countOdd = intArray.Count(myDel);               //使用委托

            Console.WriteLine($"Count of odd numbers:{countOdd}");
        }
    }
}
